package com.zhouixi.task;

import com.zhouixi.handler.HeartbeatMessageHandler;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author zr
 * @version 1.0
 * @date 2025/8/9
 */
@Component
@Slf4j
public class SessionActiveTimeTask {

    @Resource
    private HeartbeatMessageHandler heartbeatMessageHandler;

    @Scheduled(fixedDelay = 30*1000)
    public void checkSessionActive() {
        log.info("定时任务开始检查过期会话");
        heartbeatMessageHandler.scheduleHeartbeatCheck();
        log.info("定时任务结束检查过期会话,一共 {} 个会话被检查" , heartbeatMessageHandler.getSize());
    }
}
